#!/bin/bash

# 创建一个临时文件来存储SQL指令
temp_sql_file=$(mktemp)

# 将指令写入临时文件
cat <<EOF > $temp_sql_file
create table grade (name char(20),id int,score float);
insert into grade values ('Data Structure', 1, 90.5);
insert into grade values ('Data Structure', 2, 95.0);
insert into grade values ('Calculus', 2, 92.0);
insert into grade values ('Calculus', 1, 88.5);
select * from grade;
select score,name,id from grade where score > 90;
select id from grade where name = 'Data Structure';
select name from grade where id = 2 and score > 90;  
select * from grade;
update grade set score =  90 where name = 'Calculus' ;
select * from grade;
update grade set name = 'Error name' where name > 'A';
select * from grade;
update grade set name = 'Error' ,id = -1,score = 0 where name = 'Error name' and score >= 90;
select * from grade;
EOF

# 启动rmdb并将指令传入
./build/rmdb_client  < $temp_sql_file
rm $temp_sql_file
